package framework.movements;

public class ParabolicStrategy extends LinearStrategy {
	
	private int height;

	public ParabolicStrategy(LinearMovement m) {
		super(m);
		setHeight((int) Math.abs((m.getEndPoint().getX() - m.getStartPoint().getX()) /2));
	}
	
	public ParabolicStrategy(LinearMovement m, int height) {
		super(m);
		this.setHeight(height);
	}

	@Override
	public int computeX(int delta) {
		return super.computeX(delta);
	}

	@Override
	public int computeY(int delta) {
		// setting up the equation
		int c = this.height;
		float offset = (int) Math.abs((m.getEndPoint().getX() - m.getStartPoint().getX()) / 2);
		float offsetY = Math.abs(m.getY() - m.getStartPoint().getY());
		float start = -offset;
		float a = (float) (-c / Math.pow(start, 2f));
		System.out.println("x =" + (m.getX() - m.getStartPoint().getX()) + "a =" + a + ", result=" + (int) (a * Math.pow((m.getX() - m.getStartPoint().getX()), 2) + c));
		return (int) (a * Math.pow((m.getX() - m.getStartPoint().getX()), 2) + c);
	}

	public int getHeight() {
		return height;
	}

	public void setHeight(int height) {
		this.height = height;
	}
}
